package com.sduept.nwld.dataserver.rest.daily;

import com.sduept.core.dao.SuperDAO;
import com.sduept.nwld.dataserver.model.daily.BreakerStartRecord;
import com.sduept.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
 * 新设备驱动及并网管理
 * @author zq
 *
 */
@RestController
@RequestMapping("/newEquipment")
public class NewEquipmentService {
	@Autowired
	private SuperDAO dao;
	

	@GetMapping("/getNewEquipments/{start}/{end}")
	public String getNewEquipment(@PathVariable("start")String start,@PathVariable("end")String end) {
		Date s = DateUtil.getDateByString(start, DateUtil.pattern_ymd);
		Date e = DateUtil.getDateByString(end, DateUtil.pattern_ymd);
		Calendar c = Calendar.getInstance();
		c.setTime(e);
		c.add(Calendar.DAY_OF_YEAR, 1);
		c.add(Calendar.SECOND , -1);
		e = c.getTime();
		String where = " recordingTime between ? and ? ";
		List<BreakerStartRecord> obs = dao.findByCondition(BreakerStartRecord.class, where, s,e);
		return net.sf.json.JSONArray.fromObject(obs).toString();
	}
}
